<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item> <i class="el-icon-lx-cascades"></i> 讲师佣金 </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-input v-model="query.keyword" placeholder="输入订单号或讲师姓名" class="handle-input mr10"></el-input>
                <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
            </div>
            <el-table :data="tableData" class="table" ref="multipleTable" header-cell-class-name="table-header">
                <el-table-column label="讲师图片" width="100">
                    <template slot-scope="scope">
                        <img :src="scope.row.cover" @error="tabErrorPicture(scope.row.id)" alt="" class="info-image" />
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="讲师姓名"></el-table-column>
                <el-table-column prop="order_no" label="订单号"></el-table-column>
                <el-table-column label="订单金额">
                    <template slot-scope="scope">
                        <span class="red">¥ {{ scope.row.paid_fee }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="分佣金额">
                    <template slot-scope="scope">
                        <span class="red">¥ {{ scope.row.price }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="phone" label="购买用户手机号"></el-table-column>
                <el-table-column prop="paid_time" label="付款时间"></el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination
                    background
                    layout="total, prev, pager, next"
                    :current-page="query.page"
                    :page-size="query.rows"
                    :total="pageTotal"
                    @current-change="handlePageChange"
                ></el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import { commissionListData } from '../../api/index';
export default {
    // name: 'suggest',
    data() {
        return {
            query: {
                page: 1,
                rows: 4,
                keyword: ''
            },
            tableData: [],
            pageTotal: 0,
            errorProduct: require('@/assets/img/noProduct.jpg'), 
        };
    },
    created() {
        this.getData();
    },
    methods: {
        tabErrorPicture(id){    // 表格图文封面默认展示图
            let i = this.tableData.findIndex(v => v.id == id);
			this.tableData[i].cover = this.errorProduct;
        },
        getData() {
            commissionListData(this.query).then((res) => {
                this.tableData = res.data.list;
                this.pageTotal = res.data.count;
            });
        },
        // 搜索
        handleSearch() {
            this.$set(this.query);
            this.getData();
        },
        // 分页
        handlePageChange(val) {
            this.$set(this.query, 'page', val);
            this.getData();
        }
    }
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
    float: right;
}

.handle-input {
    width: 300px;
    display: inline-block;
}
.table {
    width: 100%;
    font-size: 14px;
}
.mr10 {
    margin-right: 10px;
}
.info-image {
    width: 80px;
    border-radius: 4px;
}
.red {
    color: #ea644a;
}
</style>


